/*2、有一个数组 [1,4,9,16,2,5,10,15]，生成一个新切片，要求新切片元素是数组相邻2项的和*/
package main

import "fmt"

func main() {
	s1 := [8]int{1, 4, 9, 16, 2, 5, 10, 15}
	s2 := make([]int, 7)
	var temp = 0
	for i := 0; i < len(s1); i++ {
		if i == 0 {
			temp = s1[i]
		}
		if i >= 1 {
			s2[i-1] = s1[i] + temp
			temp = s1[i]
		}
	}
	fmt.Printf("s1=%v, s2=%v", s1, s2)
}
